// 谓词(一元、二元)
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Greater
{
public:
    int base;
    Greater(): base(5) {} // 设置默认值
    Greater(int val): base(val) {} // 传入指定比较值
    // operator()接受一个参数叫一元谓词
    bool operator()(int n)
    {
        return n > base;
    }
};
void test1()
{
    vector<int> v1;
    for (int i = 0; i < 10; ++i)
    {
        v1.push_back(i);
    }
    vector<int>::iterator it1 = find_if(v1.begin(), v1.end(), Greater());
    cout << *it1 << endl;
    vector<int>::iterator it2 = find_if(v1.begin(), v1.end(), Greater(7));
    cout << *it2 << endl;
}
class MyDescend
{
public:
    // 二元谓词
    bool operator()(int a, int b)
    {
        return a > b;
    }
};
void test2()
{
    vector<int> v2;
    for (int i = 1; i < 7; ++i)
    {
        v2.push_back(10*i);
    }
    sort(v2.begin(), v2.end(), MyDescend());
    for (vector<int>::iterator it = v2.begin(); it != v2.end(); ++it)
    {
        cout << *it << endl;
    }
}
int main(void)
{
    // test1();
    test2();

    return 0;
}